<?php
/*
author: dkloz
Returns id of user upon success
Returns error code upon failure that signifies the corresponding error
*/
function BL_userLogin($username, $password)
{




    if (($id = DB_userLogin($username, $password)) < 0)
    {
    		//echo "DB userLogin returned " . $id . "<br> username: ". $username . "pass: " . $password ;
		if($id == DB_ERROR_USERLOCKED){
			UI_registerError('msg_error', "Your account is locked, due to many failed attempts. It will unlock in 5 minutes");

		}

		if($id == DB_ERROR_USERDISABLED){
			UI_registerError('msg_error', "Your account is disabled");
	
		}
		if($id == DB_ERROR_WRONGPASSWORD){
			UI_registerError('msg_error', "Wrong username or password");
		}

        return BL_USER_LOGIN;
    }
    else if ($id == "")
        return BL_USER_LOGIN;

    return $id;
}
?>
